home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: July 20, 1999
- // Author: mm
- //
- // Procedure Name:
- // getCopyAnimCurveCommands
- //
- // Description:
- // This is a helper proc which will return a string array of
- // the commands necessary to copy an animCurve
- //
- // Input Arguments:
- // string $animCurve The name of the object
- //
- // Return Value:
- // string array of commands to create a copy of the animCurve
- //
-
- global proc string[]
- getCopyAnimCurveCommands (string $animCurve)
- {
- string $commands[];
- int $entry = 0;
-
- // Make sure we are trying to copy an animCurve
- //
- if (!isAnimCurve ($animCurve)) {
- return ($commands);
- }
-
- // Set the proper units
- //
- string $angleUnits = `currentUnit -query -angle`;
- string $linearUnits = `currentUnit -query -linear`;
- string $timeUnits = `currentUnit -query -time`;
- $commands[$entry++] = "string $angleUnits = `currentUnit -query -angle`;";
- $commands[$entry++] = "string $linearUnits = `currentUnit -query -linear`;";
- $commands[$entry++] = "string $timeUnits = `currentUnit -query -time`;";
- $commands[$entry++] = (
- "currentUnit -angle " + $angleUnits +
- " -linear " + $linearUnits +
- " -time " + $timeUnits +
- ";"
- );
-
- // Create the animCurve
- //
- $commands[$entry++] = ("string $animCurve = `createNode " + `nodeType $animCurve` + "`;");
-
- // Set weighted/unweighted tangents
- //
- int $weightedTangents[] = `keyTangent -query -weightedTangents $animCurve`;
- $commands[$entry++] = ("keyTangent -edit -weightedTangents " + $weightedTangents[0] + ";");
-
- // Set infinity types
- //
- int $infinity = `getAttr ($animCurve + ".preInfinity")`;
- $commands[$entry++] = ("setAttr ($animCurve + \".preInfinity\") " + $infinity + ";");
- $infinity = `getAttr ($animCurve + ".postInfinity")`;
- $commands[$entry++] = ("setAttr ($animCurve + \".postInfinity\") " + $infinity + ";");
-
- // Set each of the keys
- //
- int $numKeys = `keyframe -query -keyframeCount $animCurve`;
- float $time[] = `keyframe -query -timeChange $animCurve`;
- float $value[] = `keyframe -query -valueChange $animCurve`;
- int $breakdown[] = `keyframe -query -breakdown $animCurve`;
- string $inTangentType[] = `keyTangent -query -inTangentType $animCurve`;
- string $outTangentType[] = `keyTangent -query -outTangentType $animCurve`;
- int $lock[] = `keyTangent -query -lock $animCurve`;
- int $weightLock[] = `keyTangent -query -weightLock $animCurve`;
- for ($key = 0; $key < $numKeys; $key++) {
- $commands[$entry++] = (
- "setKeyframe -time " + $time[$key] +
- " -value " + $value[$key] +
- " -breakdown " + $breakdown[$key] +
- ($inTangentType[$key] == "fixed" ? "" : " -inTangentType " + $inTangentType[$key]) +
- ($outTangentType[$key] == "fixed" ? "" : " -outTangentType " + $outTangentType[$key]) +
- " $animCurve;"
- );
- if ($inTangentType[$key] == "fixed") {
- float $inAngle[] = `keyTangent -index $key -query -inAngle $animCurve`;
- float $inWeight[] = `keyTangent -index $key -query -inWeight $animCurve`;
- $commands[$entry++] = (
- "keyTangent -edit -index " + $key +
- " -inTangentType fixed" +
- " -inAngle " + $inAngle[0] +
- " -inWeight " + $inWeight[0] +
- " $animCurve;"
- );
- }
- if ($outTangentType[$key] == "fixed") {
- float $outAngle[] = `keyTangent -index $key -query -outAngle $animCurve`;
- float $outWeight[] = `keyTangent -index $key -query -outWeight $animCurve`;
- $commands[$entry++] = (
- "keyTangent -edit -index " + $key +
- " -outTangentType fixed" +
- " -outAngle " + $outAngle[0] +
- " -outWeight " + $outWeight[0] +
- " $animCurve;"
- );
- }
- $commands[$entry++] = (
- "keyTangent -edit -index " + $key +
- " -lock " + $lock[$key] +
- ($weightedTangents[0] ? " -weightLock " + $weightLock[$key] : "") +
- " $animCurve;"
- );
- }
-
- // Restore the original units
- //
- $commands[$entry++] = "currentUnit -angle $angleUnits -linear $linearUnits -time $timeUnits;";
-
- return ($commands);
- }
-